<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>赛程管理</title>
	<meta name="decorator" content="default"/>
	<script>

		//		function show_Alert() {
		//
		//			alert("请先关闭上一个赛程");
		//		}

		function but(id, status) {

				if(status == 0){
						document.getElementById("but1" + id).disabled=true;
						document.getElementById("but2" +id).disabled=false;
				}
				if(status == 1){
						document.getElementById("but1" + id).disabled=false;
						document.getElementById("but2" +id).disabled=true;
				}
				console.info(id);
				$.ajax({
					type: "POST",
					url: "${ctx}/race/raceSchedule/state",
					data: {
						id:id,
						status:status
					},
					error:function(){
						console.info("error");
					}
				});
		    }
			$(document).ready(function () {

				if (${state1=="1"}) {

					document.getElementById("${sid}").style.color = "gray";
					document.getElementById("${sid}").href = "javascript:void(0)";
					document.getElementById("${sid}").onclick = function () {
					};

				} else if (${state1=="0"}) {

					document.getElementById("${sid}a").style.color = "gray";
					document.getElementById("${sid}a").href = "javascript:void(0)";
					document.getElementById("${sid}a").onclick = function () {
					};
				}

		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }

		function overtime(id){
			document.getElementById("timeId").value=id;

			$.jBox($("#overtime").html(), {
				title: "延长比赛时间", buttons: false
			});

			document.getElementById("timeId").value=id;
		}

		function teamDetails(id){
			console.info(id);
			$.ajax({
				type: "POST",
				url: "${ctx}/race/raceSchedule/teamDetails",
				data: {
					uid:id
				},
				success: function (schedule) {
					$("#teamDetails").append("<li>" +   "赛程名称："+  schedule.scheduleName  + "</li>");
					$("#teamDetails").append("<li>" +   "赛程LOGO：<img width='50px' height='60px' src='"+ schedule.scheduleLogo +"'/> </li>");
					$("#teamDetails").append("<li>" +   "赛程公告："+  schedule.scheduleNotice  + "</li>");
					$("#teamDetails").append("<li>" +   "竞赛题库："+  schedule.repertoryId  + "</li>");
					$("#teamDetails").append("<li>" +   "比赛开始时间："+  schedule.beginTime  + "</li>");
					$("#teamDetails").append("<li>" +   "比赛结束时间："+  schedule.endTime  + "</li>");
					$("#teamDetails").append("<li>" + "队伍排名切换时间：" + schedule.switchTime + "</li>");
					$("#teamDetails").append("<li>" +   "展示粒度："+  schedule.displaySize  + "</li>");
					$("#teamDetails").append("<li>" +   "加分规则：第一名交flag的队伍加  "+  schedule.plusReluI  + "分</li>");
					$("#teamDetails").append("<li>" +   "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;第二名交flag的队伍加  "+  schedule.plusReluIi  + "分</li>");
					$("#teamDetails").append("<li>" +   "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;第三名交flag的队伍加  "+  schedule.plusReluIii  + "分</li>");
					$("#teamDetails").append("<li>" +   "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;第四名交flag的队伍加  "+  schedule.plusReluIv  + "分</li>");
					$("#teamDetails").append("<li>" +   "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;第五名交flag的队伍加  "+  schedule.plusReluV  + "分</li>");
				},
				error:function(){
					console.info("error");
				}
			});

		$.jBox($("#teamDetailsBox").html(), {title:"赛情详情", buttons:{"关闭":true}, submit: function(){}});
		}


	</script>

	<script type="text/template" id="teamDetailsBox">
		<div>
			<ul id="teamDetails" style="list-style:none">
			</ul>
		</div>
	</script>

	<script type="text/template" id="teamDetailsBox1">
		<div>

		</div>
	</script>
</head>
<body>
<div id="overtime" class="hide">
	<form id="importForm" action="${ctx}/race/raceSchedule/overtime" method="post" enctype="multipart/form-data" class="form-search" style="padding-left:20px;text-align:center;"><br/>
			<input name="timeId" id="timeId"  style="width: 30px" type="hidden"/><br/>
	        延长	<input name="time" style="width: 30px"  type="text"/>分钟<br/><br/>

		<input id="btnImportSubmit" class="btn btn-primary" type="submit" value="   确定   "/>
	</form>

</div>

	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/race/raceSchedule/">赛程列表</a></li>
		<shiro:hasPermission name="race:raceSchedule:edit"><li><a href="${ctx}/race/raceSchedule/form">新建赛程</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="raceSchedule" action="${ctx}/race/raceSchedule/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>赛程名称：</label>
				<form:input path="scheduleName" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="btns"><div style="width: 50px"></div></li>
			<li class="btns"><a style="color: red" target="view_window" href="${ctxf}/race/raceLogin"> 竞赛登录页面 </a></li>
			<li class="btns"><a style="color: red" target="view_window" href="${ctxf}/race/present"> 竞赛呈现页面 </a></li>


			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>

				<th>赛程名称</th>
				<th>赛程状态</th>

				<shiro:hasPermission name="race:raceSchedule:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<sys:message content="${message}"/>
		<c:forEach items="${page.list}" var="raceSchedule">
			<tr>
				<td><a href="${ctx}/race/raceSchedule/form?id=${raceSchedule.id}">
						${raceSchedule.scheduleName}
				</a></td>

				<td>

					<c:if test="${state1=='1'}">

						<a id="${raceSchedule.id}" onclick="return confirmx('请先关闭正在开启的赛程！', this.href)"
						   href="javascript:void(0)" style="color: #31A6E2">开启</a>

					</c:if>

					<c:if test="${state1=='0'||state1==''||state1==null}">
						<a id="${raceSchedule.id}" onclick="return confirmx('确认要开启该赛程吗？', this.href)"
						   href="${ctx}/race/raceSchedule/state?id=${raceSchedule.id}&status=0">开启 </a>
					</c:if>


					&nbsp; &nbsp; &nbsp;&nbsp;
					<a id="${raceSchedule.id}a" onclick="return confirmx('确认要关闭该赛程吗？', this.href)"
					   href="${ctx}/race/raceSchedule/state?id=${raceSchedule.id}&status=1">关闭 </a>
				</td>

				<shiro:hasPermission name="race:raceSchedule:edit"><td>
					<a href="javascript:overtime('${raceSchedule.id}')">延长比赛时间</a>&nbsp;&nbsp;&nbsp;
					<a href="javascript:teamDetails('${raceSchedule.id}')">详情</a>&nbsp;&nbsp;&nbsp;
    				<a href="${ctx}/race/raceSchedule/form?id=${raceSchedule.id}">编辑</a>&nbsp;&nbsp;&nbsp;
					<a href="${ctx}/race/raceSchedule/formCopy?id=${raceSchedule.id}">复制</a>&nbsp;&nbsp;&nbsp;
					<a href="${ctx}/race/raceSchedule/delete?id=${raceSchedule.id}" onclick="return confirmx('确认要删除该赛程管理吗？', this.href)">删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>

<div class="pagination">${page}</div>
</body>


</html>